
function []= irisdataclassify()

% @ Ayan Acharya, Date: 3.5.2011

clc;
clear;
warning off;

data=load('iris.dat');
N=size(data,1);
datalabel=data(:,end);
data=data(:,1:end-1);

CUTOFF   = 2;
pcntgs   = 10;
MAXCOUNT = 1;
alpha    = 0.001;
lambda   = 0.1;
numiter  = 100;

for count=1:MAXCOUNT
    count
    
    trainsize=round((pcntgs/100)*N);
    testsize=N-trainsize;
    
    
    % selecting index of traning data
    Xvtrainindex=[];
    
    for i=1:trainsize
        temp=0;
        while(temp==0 || isempty(find(Xvtrainindex==temp))==0)
            temp = round((N-1)*rand)+1;
        end
        Xvtrainindex(i) = temp;
    end
    
    % constructing training data
    
    Xvtrain     = data(Xvtrainindex',:);
    Yvtrain     = datalabel(Xvtrainindex');
    
    % constructing test data
    
    dataindex   = [1:N];
    Xvtestindex = setdiff(dataindex, Xvtrainindex);
    Xvtest      = data(Xvtestindex',:);
    Yvtesttrue  = datalabel(Xvtestindex);
    
    % Classifier Ensemble
    
    [YvtestDT, accuracyDT]   = DTclassify (Xvtrain, Yvtrain, Xvtest, Yvtesttrue);
    [YvtestGLM, accuracyGLM] = genlogit (Xvtrain, Yvtrain, Xvtest, Yvtesttrue);
    %[Yvtestlda, accuracylda] = ldaclassify (Xvtrain, Yvtrain, Xvtest, Yvtesttrue);
    [Yvtestnvb, accuracynvb] = nvbclassify (Xvtrain, Yvtrain, Xvtest, Yvtesttrue);
    
    piSet=[YvtestDT+YvtestGLM+Yvtestnvb]/3;
    [~,tempSet]=max(piSet,[],2);
    avgacc = (100/size(tempSet,1))*size(find(tempSet==Yvtesttrue),1);
    accs   = [accuracyDT; accuracyGLM; accuracynvb];
    maxacc = max(accs);
    
    % Clustering Ensemble
    
    CUTOFFmat=[CUTOFF:CUTOFF+5];
    
    SSetH1=zeros(testsize,testsize);
    SSetH2=zeros(testsize,testsize);
    SSetS1=zeros(testsize,testsize);
    
    
    % [~,DTres]  = max(YvtestDT');
    % [~,GLMres] = max(YvtestGLM');
    % [~,ldares] = max(Yvtestlda');
    % ensemble = [DTres' GLMres' ldares'];
    
    
    for i=1:size(CUTOFFmat,2)
        
        Clnum   = CUTOFFmat(i);
        Xvtest  = compute_mapping([Yvtesttrue Xvtest], 'LDA', 3);
        
        TH1     = CLUSTERDATA(Xvtest,Clnum);
        TexH1   = expandT(TH1,Clnum);
        SSetH1  = SSetH1+TexH1*TexH1';
        
        TH2     = kmeans(Xvtest,Clnum);
        TexH2   = expandT(TH2,Clnum);
        SSetH2  = SSetH2+TexH2*TexH2';
        
        options = [2,100,1e-5,0];
        [~,TS1] = fcm(Xvtest,Clnum,options);
        TS1     = TS1';
        SSetS1  = SSetS1+TS1*TS1';
        %ensemble = [ensemble T];
        
    end
    
    SSetH1  = SSetH1/size(CUTOFFmat,2);
    SSetH2  = SSetH2/size(CUTOFFmat,2);
    SSetS1  = SSetS1/size(CUTOFFmat,2);
    
    [CCCEH1,~]=call_CCCE(piSet, SSetH1, Yvtesttrue, alpha, lambda, numiter);
    [CCCEH2,~]=call_CCCE(piSet, SSetH2, Yvtesttrue, alpha, lambda, numiter);
    [CCCES1,~]=call_CCCE(piSet, SSetS1, Yvtesttrue, alpha, lambda, numiter);
    
    accvals = [maxacc avgacc CCCEH1 CCCEH2 CCCES1]  
    
    %[Ut]= BGCM_simple(ensemble, 2, 3, 1, 0.01);
    %[~,At]=max(Ut');
    %accuracyBGCM=100*length(find(At'==Yvtesttrue))/testsize
    %cp=bgcmmod(ensemble,3,3,2,1,2,100,[],[])
    
end

end


